package Students;
import java.util.Scanner;
import java.util.ArrayList;

public class StudentOp {
    Scanner sc=new Scanner(System.in);
    ArrayList<Student>arr;
    public StudentOp(ArrayList<Student>arr){
        this.arr=arr;
    }
    public void modify(){
        System.out.println("请输入想修改的学生的序号：");
        int num= sc.nextInt();
        System.out.println("请输入想修改的属性：");
        String s = sc.next();
        switch (s){
            case "name":
            String name=sc.next();
            arr.get(num).setName(name);
            break;
            case "age":
            int age= sc.nextInt();
            arr.get(num).setAge(age);
            break;
            case "sex":
            String sex= sc.next();
            arr.get(num).setSex(sex);
            break;
            case "telephone":
            String telephone= sc.next();
            arr.get(num).setTelephone(telephone);
            break;
            case "number":
            int number= sc.nextInt();
            arr.get(num).setNumber(number);
            break;
        }
        for (int j = 0; j <arr.size() ; j++) {
            arr.get(j).String();
        }
    }
    public void add(){
        System.out.println("请输入想添加的内容：");
        Student st1=new Student();
        System.out.println("请输入姓名：");
        String name=sc.next();
        st1.setName(name);
        System.out.println("请输入年龄：");
        int age=sc.nextInt();
        st1.setAge(age);
        System.out.println("请输入性别：");
        String sex=sc.next();
        st1.setSex(sex);
        System.out.println("请输入联系方式：");
        String tele=sc.next();
        st1.setTelephone(tele);
        System.out.println("请输入学号：");
        int num=sc.nextInt();
        st1.setNumber(num);
        arr.add(st1);
        for (int j = 0; j <arr.size() ; j++) {
            arr.get(j).String();
        }
    }
    public void select(){
        System.out.println("请输入想查询的学生的序号：");
        int num=sc.nextInt();

        arr.get(num).String();

    }
    public void delete(){
        System.out.println("请输入想删除的学生的序号：");
        int num= sc.nextInt();
        arr.remove((num-1));
        for (int j = 0; j <arr.size() ; j++) {
            arr.get(j).String();
        }
    }
}
